/**
 *
 */
import OpenApi;
import OpenApi.OpenApiUtil;

extends OpenApi;


init(config: OpenApiUtil.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('aimath', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!$isNull(endpoint)) {
    return endpoint;
  }
  
  if (!$isNull(endpointMap) && !$isNull(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return OpenApiUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model ChatMessageRequest {
  content?: string(name='Content', description='This parameter is required.', example='hello world！'),
  conversationId?: string(name='ConversationId', description='This parameter is required.', example='723b7f0f-c28a-4123-86e7-094d3d3863f8'),
  userId?: string(name='UserId', description='This parameter is required.', example='c28a-4123-86e7'),
}

model ChatMessageResponseBody = {
  content?: string(name='Content'),
  errCode?: string(name='ErrCode', example='Param.Invalid'),
  errMsg?: string(name='ErrMsg', example='The specified parameter is not valid.'),
  eventType?: string(name='EventType'),
  requestId?: string(name='RequestId', description='Id of the request', example='696acaa9-eb29-4c1f-b48a-1f901579acc5'),
  success?: boolean(name='Success', example='true'),
}

model ChatMessageResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ChatMessageResponseBody(name='body'),
}

/**
 * @summary 聊天消息API
 *
 * @param request ChatMessageRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ChatMessageResponse
 */
async function chatMessageWithOptions(request: ChatMessageRequest, runtime: $RuntimeOptions): ChatMessageResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.content)) {
    body['Content'] = request.content;
  }
  if (!$isNull(request.conversationId)) {
    body['ConversationId'] = request.conversationId;
  }
  if (!$isNull(request.userId)) {
    body['UserId'] = request.userId;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'ChatMessage',
    version = '2024-11-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 聊天消息API
 *
 * @param request ChatMessageRequest
 * @return ChatMessageResponse
 */
async function chatMessage(request: ChatMessageRequest): ChatMessageResponse {
  var runtime = new $RuntimeOptions{};
  return chatMessageWithOptions(request, runtime);
}

model CreateConversationRequest {
  exerciseAnalysis?: string(name='ExerciseAnalysis'),
  exerciseAnswer?: string(name='ExerciseAnswer'),
  exerciseContent?: string(name='ExerciseContent', description='This parameter is required.'),
  exerciseType?: string(name='ExerciseType'),
  outerBizId?: string(name='OuterBizId', description='This parameter is required.', example='2r560eHAbsknrfHXVZO4L'),
  userId?: string(name='UserId', description='This parameter is required.', example='wx-xx-yy'),
}

model CreateConversationResponseBody = {
  conversationId?: string(name='ConversationId', example='a499fef7-fef7-453c-a6b2-6a34089613e8'),
  errCode?: string(name='ErrCode', example='InternalError'),
  errMsg?: string(name='ErrMsg', example='The request processing has failed due to some unknown error.'),
  requestId?: string(name='RequestId', description='Id of the request', example='89C27D03-4C85-5420-9752-989130878F4D'),
  success?: boolean(name='Success', example='true'),
}

model CreateConversationResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateConversationResponseBody(name='body'),
}

/**
 * @summary 创建试题相应的对话。
 *
 * @param request CreateConversationRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateConversationResponse
 */
async function createConversationWithOptions(request: CreateConversationRequest, runtime: $RuntimeOptions): CreateConversationResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.exerciseAnalysis)) {
    body['ExerciseAnalysis'] = request.exerciseAnalysis;
  }
  if (!$isNull(request.exerciseAnswer)) {
    body['ExerciseAnswer'] = request.exerciseAnswer;
  }
  if (!$isNull(request.exerciseContent)) {
    body['ExerciseContent'] = request.exerciseContent;
  }
  if (!$isNull(request.exerciseType)) {
    body['ExerciseType'] = request.exerciseType;
  }
  if (!$isNull(request.outerBizId)) {
    body['OuterBizId'] = request.outerBizId;
  }
  if (!$isNull(request.userId)) {
    body['UserId'] = request.userId;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'CreateConversation',
    version = '2024-11-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 创建试题相应的对话。
 *
 * @param request CreateConversationRequest
 * @return CreateConversationResponse
 */
async function createConversation(request: CreateConversationRequest): CreateConversationResponse {
  var runtime = new $RuntimeOptions{};
  return createConversationWithOptions(request, runtime);
}

model CreateRelatedConversationRequest {
  exerciseCode?: string(name='ExerciseCode', description='This parameter is required.', example='Ex_pop_1731848070815_funI'),
  outerBizId?: string(name='OuterBizId', description='This parameter is required.', example='725e5550-8f81-42e0-a4db-d2de1be52afc'),
  userId?: string(name='UserId', description='This parameter is required.', example='pop_1731848070815'),
}

model CreateRelatedConversationResponseBody = {
  conversationId?: string(name='ConversationId', example='96d36ed0-ebde-11ee-806f-f35ee6682ec5'),
  errCode?: string(name='ErrCode', example='InternalError'),
  errMsg?: string(name='ErrMsg', example='The request processing has failed due to some unknown error.'),
  requestId?: string(name='RequestId', description='Id of the request', example='1d31b11b-4b82-4db1-b3c0-001529fc78eb'),
  success?: boolean(name='Success', example='true'),
}

model CreateRelatedConversationResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateRelatedConversationResponseBody(name='body'),
}

/**
 * @summary 创建关联的对话，输入试题code即可开启对话
 *
 * @param request CreateRelatedConversationRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateRelatedConversationResponse
 */
async function createRelatedConversationWithOptions(request: CreateRelatedConversationRequest, runtime: $RuntimeOptions): CreateRelatedConversationResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.exerciseCode)) {
    body['ExerciseCode'] = request.exerciseCode;
  }
  if (!$isNull(request.outerBizId)) {
    body['OuterBizId'] = request.outerBizId;
  }
  if (!$isNull(request.userId)) {
    body['UserId'] = request.userId;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'CreateRelatedConversation',
    version = '2024-11-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 创建关联的对话，输入试题code即可开启对话
 *
 * @param request CreateRelatedConversationRequest
 * @return CreateRelatedConversationResponse
 */
async function createRelatedConversation(request: CreateRelatedConversationRequest): CreateRelatedConversationResponse {
  var runtime = new $RuntimeOptions{};
  return createRelatedConversationWithOptions(request, runtime);
}

model GenAnalysisRequest {
  exerciseContent?: string(name='ExerciseContent', description='This parameter is required.'),
}

model GenAnalysisResponseBody = {
  content?: string(name='Content'),
  errCode?: string(name='ErrCode', example='40020503'),
  errMsg?: string(name='ErrMsg', example='Parameter value validation failed'),
  eventType?: string(name='EventType'),
  requestId?: string(name='RequestId', description='Id of the request', example='1d31b11b-4b82-4db1-b3c0-001529fc78eb'),
}

model GenAnalysisResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GenAnalysisResponseBody(name='body'),
}

/**
 * @summary 生成解题分析
 *
 * @param request GenAnalysisRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GenAnalysisResponse
 */
async function genAnalysisWithOptions(request: GenAnalysisRequest, runtime: $RuntimeOptions): GenAnalysisResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.exerciseContent)) {
    body['ExerciseContent'] = request.exerciseContent;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'GenAnalysis',
    version = '2024-11-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 生成解题分析
 *
 * @param request GenAnalysisRequest
 * @return GenAnalysisResponse
 */
async function genAnalysis(request: GenAnalysisRequest): GenAnalysisResponse {
  var runtime = new $RuntimeOptions{};
  return genAnalysisWithOptions(request, runtime);
}

model GenStepRequest {
  exerciseCode?: string(name='ExerciseCode', description='This parameter is required.', example='Ex_pop_1731848070815_funI'),
}

model GenStepResponseBody = {
  content?: string(name='Content'),
  errCode?: string(name='ErrCode', example='40020503'),
  errMsg?: string(name='ErrMsg', example='Parameter value validation failed'),
  eventType?: string(name='EventType'),
  requestId?: string(name='RequestId', description='Id of the request', example='696acaa9-eb29-4c1f-b48a-1f901579acc5'),
}

model GenStepResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GenStepResponseBody(name='body'),
}

/**
 * @summary 生成数学解题步骤
 *
 * @param request GenStepRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GenStepResponse
 */
async function genStepWithOptions(request: GenStepRequest, runtime: $RuntimeOptions): GenStepResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.exerciseCode)) {
    body['ExerciseCode'] = request.exerciseCode;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'GenStep',
    version = '2024-11-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 生成数学解题步骤
 *
 * @param request GenStepRequest
 * @return GenStepResponse
 */
async function genStep(request: GenStepRequest): GenStepResponse {
  var runtime = new $RuntimeOptions{};
  return genStepWithOptions(request, runtime);
}

model GlobalConfirmRequest {
  exerciseCode?: string(name='ExerciseCode', description='This parameter is required.', example='Ex_pop_1731848070815_funI'),
  tag?: string(name='Tag', example='2024-11-18'),
}

model GlobalConfirmResponseBody = {
  errCode?: string(name='ErrCode', example='40020503'),
  errMsg?: string(name='ErrMsg', example='Parameter value validation failed'),
  requestId?: string(name='RequestId', description='Id of the request', example='696acaa9-eb29-4c1f-b48a-1f901579acc5'),
  success?: boolean(name='Success', example='true'),
}

model GlobalConfirmResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GlobalConfirmResponseBody(name='body'),
}

/**
 * @summary 全局确认修订完成
 *
 * @param request GlobalConfirmRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GlobalConfirmResponse
 */
async function globalConfirmWithOptions(request: GlobalConfirmRequest, runtime: $RuntimeOptions): GlobalConfirmResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.exerciseCode)) {
    body['ExerciseCode'] = request.exerciseCode;
  }
  if (!$isNull(request.tag)) {
    body['Tag'] = request.tag;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'GlobalConfirm',
    version = '2024-11-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 全局确认修订完成
 *
 * @param request GlobalConfirmRequest
 * @return GlobalConfirmResponse
 */
async function globalConfirm(request: GlobalConfirmRequest): GlobalConfirmResponse {
  var runtime = new $RuntimeOptions{};
  return globalConfirmWithOptions(request, runtime);
}

model UpdateAnalysisRequest {
  content?: string(name='Content', description='This parameter is required.'),
  contentCode?: string(name='ContentCode', description='This parameter is required.', example='1549d636-b102-4fee-8a99-fcc552aa9aa9'),
  exerciseCode?: string(name='ExerciseCode', description='This parameter is required.', example='Ex_pop_1731848070815_funI'),
}

model UpdateAnalysisResponseBody = {
  errCode?: string(name='ErrCode', example='9901100002'),
  errMsg?: string(name='ErrMsg', example='Parameter value validation failed'),
  requestId?: string(name='RequestId', description='Id of the request', example='89C27D03-4C85-5420-9752-989130878F4D'),
  success?: boolean(name='Success', example='true'),
}

model UpdateAnalysisResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateAnalysisResponseBody(name='body'),
}

/**
 * @summary 修订解题分析
 *
 * @param request UpdateAnalysisRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateAnalysisResponse
 */
async function updateAnalysisWithOptions(request: UpdateAnalysisRequest, runtime: $RuntimeOptions): UpdateAnalysisResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.content)) {
    body['Content'] = request.content;
  }
  if (!$isNull(request.contentCode)) {
    body['ContentCode'] = request.contentCode;
  }
  if (!$isNull(request.exerciseCode)) {
    body['ExerciseCode'] = request.exerciseCode;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'UpdateAnalysis',
    version = '2024-11-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 修订解题分析
 *
 * @param request UpdateAnalysisRequest
 * @return UpdateAnalysisResponse
 */
async function updateAnalysis(request: UpdateAnalysisRequest): UpdateAnalysisResponse {
  var runtime = new $RuntimeOptions{};
  return updateAnalysisWithOptions(request, runtime);
}

model UpdateStepRequest {
  content?: string(name='Content', description='This parameter is required.'),
  contentCode?: string(name='ContentCode', description='This parameter is required.', example='1549d636-b102-4fee-8a99-fcc552aa9aa9'),
  exerciseCode?: string(name='ExerciseCode', description='This parameter is required.', example='Ex_pop_1731848070815_funI'),
}

model UpdateStepResponseBody = {
  errCode?: string(name='ErrCode', example='9901100002'),
  errMsg?: string(name='ErrMsg', example='Parameter value validation failed'),
  requestId?: string(name='RequestId', description='Id of the request', example='15486286-243F-51E6-8DD3-B2D2365E5136'),
  success?: boolean(name='Success', example='true'),
}

model UpdateStepResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateStepResponseBody(name='body'),
}

/**
 * @summary 修订解题步骤
 *
 * @param request UpdateStepRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateStepResponse
 */
async function updateStepWithOptions(request: UpdateStepRequest, runtime: $RuntimeOptions): UpdateStepResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.content)) {
    body['Content'] = request.content;
  }
  if (!$isNull(request.contentCode)) {
    body['ContentCode'] = request.contentCode;
  }
  if (!$isNull(request.exerciseCode)) {
    body['ExerciseCode'] = request.exerciseCode;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'UpdateStep',
    version = '2024-11-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 修订解题步骤
 *
 * @param request UpdateStepRequest
 * @return UpdateStepResponse
 */
async function updateStep(request: UpdateStepRequest): UpdateStepResponse {
  var runtime = new $RuntimeOptions{};
  return updateStepWithOptions(request, runtime);
}

